<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <link rel="icon" type="image/x-icon" href="/signin/favicon.ico"/>
    <title>登录</title>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        body {
            font: 12px/1.5 "Microsoft YaHei", tahoma, arial, 'Hiragino Sans GB', '\5b8b\4f53', sans-serif;
        }

        ul, li, i {
            list-style: none;
            font-style: normal
        }

        form {
            width: 500px;
            margin: 30px auto;
            color: #6C6C6C;
        }

        p {
            height: 30px;
            line-height: 30px;
            margin-bottom: 26px;
            position: relative;
        }

        label {
            float: left;
            width: 100px;
            text-align: right;
            font-size: 14px;
        }

        span {
            font-size: 12px;
        }

        #sub {
            list-style: none;
            background-color: #2d8cf0;
            border: 1px solid #2d8cf0;
            color: #fff !important;
            margin-top: 0px;
            line-height: 36px;
            height: 36px;
            width: 120px;
            display: inline-block;
            text-align: center;
            text-decoration: none;
            vertical-align: middle;
            cursor: pointer;
            font-size: 14px;
            font-weight: 700;
            border-radius: 2px;
            padding: 0 20px;
            margin-left: 80px;
            margin-top: 10px;
        }

        #home {
            list-style: none;
            background-color: #2d8cf0;
            border: 1px solid #2d8cf0;
            color: #fff !important;
            margin-top: 0px;
            line-height: 36px;
            height: 36px;
            width: 120px;
            display: inline-block;
            text-align: center;
            text-decoration: none;
            vertical-align: middle;
            cursor: pointer;
            font-size: 14px;
            font-weight: 700;
            border-radius: 2px;
            padding: 0 20px;
            margin-left: 50px;
            margin-top: 10px;
        }

        p input {
            float: left;
            font-size: 12px;
            color: #6C6C6C;
            vertical-align: middle;
            border: 1px solid #ddd;
            height: 24px;
            width: 300px;
            line-height: 24px;
            padding: 3px 10px;
            margin-right: 8px;
        }

        p button {
            float: left;
            font-size: 12px;
            color: #6C6C6C;
            vertical-align: middle;
            border: 1px solid #ddd;
            height: 32px;
            width: 120px;
            line-height: 24px;
            padding: 3px 10px;
            margin-right: 8px;
            cursor: pointer;
            outline-color: white;
        }

        #yzm, #imgCode {
            width: 88px;
        }

        .getYzm {
            outline-color: #fff;
            background: #FFF1E8;
            border: 1px solid #FF751A;
            height: 100%;
            white-space: nowrap;
            padding: 0 4px;
            width: 150px;
            color: #FF6A00;
            border-radius: 3px;
        }

        p span {
            display: none;
            font-size: 14px;
            color: #ff5243;
            position: absolute;
            top: 28px;
            left: 100px;
        }

        span img {
            width: 16px;
            margin-bottom: -3px;
        }

        span b {
            font-weight: 400;
            font-size: 12px;
        }

        h4 {
            float: left;
            font-weight: 400;
        }

        p.err input {
            border-color: #ff5243;
        }

        p.err span {
            display: block;
        }

        p .success {
            color: #b7b7b7;
        }

        #kaptcha {
            display: block;
        }

        .step {
            width: 800px;
            margin: 0 auto;
            margin-top: 60px;
            position: relative;
        }

        .step:after {
            display: block;
            content: '.';
            height: 0;
            clear: both;
            visibility: hidden;
        }

        .step li {
            float: left;
            width: 33%;
            height: 54px;
            position: relative;
        }

        .ul-line {
            height: 3px;
            background: #b9b9b9;
            display: block;
            margin-top: 14px;
            line-height: 1;
            overflow: hidden;
        }

        .ul-icon {
            height: 50px;
            position: absolute;
            top: 0;
            width: 150px;
            text-align: center;
            left: -25px;
        }

        .iconfont {
            display: block;
            width: 30px;
            height: 30px;
            margin: 0;
            line-height: 30px;
            background: #fff;
            padding: 0 10px;
            position: absolute;
            top: 0;
            left: 0;
            text-shadow: 1px 1px 2px #fff, 0 0 0 #ccc, 1px 1px 2px #fff;
            background: #FFFFFF;
        }

        .iconfont:before {
            display: block;
            content: '';
            position: absolute;
            width: 30px;
            height: 30px;
            background: #b7b7b7;
            transform: rotate(45deg);
            border-radius: 6px;
        }

        .ul-number {
            font-size: 14px;
            line-height: 14px;
            position: absolute;
            top: 7px;
            left: 0;
            padding: 0 20px;
            font-weight: 700;
            color: #fff;
        }

        .step span {
            display: block;
            height: 30px;
            line-height: 30px;
            position: relative;
            text-shadow: 0 1px 0 #fff;
            top: 34px;
            left: -50px;
            color: #b7b7b7;
            font-size: 14px;
        }

        .step .step-end {
            position: absolute;
            top: 0;
            right: -140px;
            width: 150px;
            zoom: 1;
        }

        .step .active .iconfont:before, .step li:nth-of-type(1) .iconfont:before {
            background: #00C1DE;
        }

        .step .active span {
            color: #00C1DE;
        }

        .step li:nth-of-type(1) .ul-line {
            background: #00C1DE;
        }

        .div-bar {
            background: #2d8cf0;
            width: 100%;
            height: 50px;
            text-align: center;
            line-height: 50px;
            font-size: 20px;

        }
    </style>
</head>
<body>
<div class="div-bar"><font color="white">忘记密码</font></div>
<ul class="step">
    <li class="active">
        <div class="ul-line"></div>
        <div class="ul-icon">
            <i class="iconfont"></i>
            <i class="ul-number">1</i>
            <span>验证身份</span>
        </div>
    </li>
    <li class="active">
        <div class="ul-line"></div>
        <div class="ul-icon">
            <i class="iconfont"></i>
            <i class="ul-number">2</i>
            <span>发送邮件</span>
        </div>
    </li>
    <li>
        <div class="ul-line"></div>
        <div class="ul-icon">
            <i class="iconfont"></i>
            <i class="ul-number">3</i>
            <span>找回密码</span>
        </div>
    </li>
    <li class="step-end">
        <div class="ul-icon">
            <i class="iconfont"></i>
            <i class="ul-number">√</i>
            <span>完成</span>
        </div>
    </li>
</ul>
<form>
    <p class="email">
        <label>邮箱：</label>
        <i></i>
    </p>
    <p class="yzmP">
        <label for="yzm">验证码：</label>
        <input type="text" name="yzm" id="yzm"/>

        <input type="button" value="获取邮件验证码" id="getYzm" class="getYzm"/>
        <span><img src="/signin/image/err.png"/><b>验证码错误</b></span>
        <span class="success"><img src="/signin/image/success.png"/><b>验证码已发送到您的邮箱，两分钟内有效</b></span>
    </p>
    <p><input id="sub" type="button" value="下一步"/><label> </label><input id="home" type="button" value="返回"/></p>
</form>
<script src="/signin/js/jQuery.3.3.1.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    $(function () {
        var admin = JSON.parse(localStorage.getItem('admin'));
        var emailName = admin.email;
        var countdown = 60;
        emailName = emailName.substring(0, 3) + '*******@' + emailName.split('@')[1];
        $('.email i').html(emailName);
        $('#getYzm').click(function (e) {
            if (countdown == 60) {
                $('p').removeClass('err')
                var mail = {
                    account: admin.user,
                    email: admin.email
                };
                $('#getYzm').attr('disabled', "true");
                $.post("/signin/user/sendValidateEmail", mail, function (result) {
                    console.log(result.code)
                    if (result.code == 200) {
                        settime($('#getYzm'))
                        $('.success').css('display', 'block');
                    } else if (result.code == 401) {
                        err('.yzm', '验证码发送失败')

                    }

                });
            }

        })

        $('#home').click(function () {
            $.post("/signin/user/gohome", null, function (result) {
                window.location.href = result.result;
            });

        })

        $('#sub').click(function (e) {
            var yzm = $('#yzm').val();
            $('p').removeClass('err')
            $('.success').css('display', 'none')
            if (yzm == '') {
                err('.yzmP', '请输入验证码')
            } else {
                var mail = {
                    email: admin.email,
                    account: admin.user,
                    code: yzm
                }
                $.post("/signin/user/validateEmail", mail, function (result) {
                    console.log(result.code)
                    if (result.code == 200) {
                        document.cookie = 'tmp_token=' + result.result + ';path=/signin';
                        window.location.href = '/signin/user/password/resetPass';
                    } else if (result.code == 401 && result.message == '验证失败') {
                        err('.yzmP', '验证码错误')
                    } else if (result.code == 401 && result.message == '验证码已失效') {
                        err('.yzmP', '验证码已失效，请重新发送')
                    } else {
                        alert(result.message);
                    }
                });
            }
        })

        function err(name, txt) {
            $(name).addClass('err');
            $(name).find('b').eq(0).html(txt)
        }

        function settime(e) {
            if (countdown == 0) {
                $('.success').css('display', 'none');
                e.attr('disabled', false);
                e.val("获取邮件验证码");
                countdown = 60;
                return;
            } else {
                e.attr('disabled', true);
                e.val("重新发送(" + countdown + "s)");
                countdown--;
                setTimeout(function () {
                    settime(e)
                }, 1000)
            }
        }
    })
</script>
</body>
</html>
